package day38;

public enum EnumWeekDay {
    //1、定义枚举常量, 2、并添加分号
    MONDAY("星期一"), TUESDAY("星期二"), WEDNESDAY("星期三"),
    THURSDAY("星期四"), FRIDAY("星期五"), SATURDAY("星期六"), SUNDAY("星期日");

    // 3、创建私有变量；
    private String weekday;

    //4、编写私有有参构造方法；
    private EnumWeekDay(String weekday) {
        System.out.println(weekday);
        this.weekday = weekday;
    }
    //5、覆盖toString()方法
    @Override
    public String toString() {
        return this.weekday;
    }

}
class WeekDayDemo {
    public static void main(String[] args) {
        //结果本质上都是EnumWeekDay对象，底层相当于调用了EnumWeekDay默认构造方法创建一个对象，将所有的数据存入数组
        System.out.println(EnumWeekDay.MONDAY.getClass().getName());
        System.out.println(EnumWeekDay.MONDAY);
        System.out.println(EnumWeekDay.TUESDAY);
        System.out.println(EnumWeekDay.WEDNESDAY);
        System.out.println(EnumWeekDay.THURSDAY);
        System.out.println(EnumWeekDay.FRIDAY);
        System.out.println(EnumWeekDay.SATURDAY);
        System.out.println(EnumWeekDay.SUNDAY);
        System.out.println(EnumWeekDay.SUNDAY);

        System.out.println(EnumWeekDay.MONDAY.ordinal());
        System.out.println(EnumWeekDay.TUESDAY.ordinal());
        System.out.println(EnumWeekDay.WEDNESDAY.ordinal());
        System.out.println(EnumWeekDay.THURSDAY.ordinal());
        System.out.println(EnumWeekDay.FRIDAY.ordinal());
        System.out.println(EnumWeekDay.SATURDAY.ordinal());
        System.out.println(EnumWeekDay.SUNDAY.ordinal());
    }
}